<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>删除医生</title>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<div class="container mt-5">
    <h2>删除医生</h2>
    <form id="deleteDoctorForm">
        <div class="mb-3">
            <label for="doctorId" class="form-label">请输入要删除的医生ID</label>
            <input type="number" class="form-control" id="doctorId" name="doctorId" required>
        </div>
        <button type="submit" class="btn btn-danger">确认删除</button>
    </form>
</div>

<script src="/js/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        $('#deleteDoctorForm').on('submit', function (e) {
            e.preventDefault();
            const id = $('#doctorId').val();

            $.ajax({
                url: "/admins/deleteDoctor/" + id,
                type: "DELETE",
                success: function () {
                    alert("医生删除成功");
                    window.location.href = "/doctorList";
                },
                error: function () {
                    alert("删除失败");
                }
            });
        });
    });
</script>

</body>
</html>
